#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2017/08/23 16:16
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
"""

from flask import Flask
from flask import make_response
from flask import redirect
from flask import abort

app = Flask(__name__)

@app.route('/')
def index():
    response =make_response('<h1>This document carries a cookie!</h1>')
    response.set_cookie('answer','42')
    return response

@app.route('/re')
def re():
    return redirect('http://www.baidu.com')

@app.route('/user/<id>')
def get_user(id):
    user = id
    if not user:
        abort(404)
    return '<h1>Hello, %s</h1>' % user


if __name__ == '__main__':
    app.run(debug = True)